//
//  LeadPageViewController.m
//  BTRIP
//
//  Created by Rain on 15/11/25.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "LeadPageViewController.h"

@interface LeadPageViewController ()<UIScrollViewDelegate>

@property (nonatomic, retain) UIScrollView *scrollView;

@end

@implementation LeadPageViewController

- (void)dealloc
{
    [_scrollView release];
    
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self createScrollView];
}

- (void)createScrollView {
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH, KHEIGHT)];
    _scrollView.contentSize = CGSizeMake(KWIDTH, KHEIGHT);
    _scrollView.pagingEnabled = YES;
    _scrollView.delegate = self;
    
    for (int i = 0; i < 1; i++) {
        UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg", i + 1]]];
        imageView.frame = CGRectMake(self.view.frame.size.width * i, 0, self.view.frame.size.width, self.view.frame.size.height);
        [_scrollView addSubview:imageView];
        [imageView release];
    }
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(100, self.view.frame.size.height - 73, self.view.frame.size.width / 3 + 50, 52);
    [button.layer setCornerRadius:27.0];
    
    button.backgroundColor = [UIColor colorWithRed:48/255 green:55/255 blue:64/255 alpha:0.8];
    [button setTitle:@"点击进入" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [_scrollView addSubview:button];
    [self.view addSubview:_scrollView];
    [_scrollView release];
    
}

- (void)buttonAction:(UIButton *)button {
    self.myblock(YES);
}

- (void)leadPage:(block)block {
    self.myblock = block;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
